# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Michael Mason <ms13sp@gmail.com>
pkgname=tinyproxy
pkgver=1.10.0
pkgrel=3
pkgdesc="Lightweight HTTP proxy"
pkgusers="tinyproxy"
pkggroups="tinyproxy"
url="https://tinyproxy.github.io/"
arch="all"
license="GPL-2.0-or-later"
makedepends="asciidoc"
install="tinyproxy.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/tinyproxy/tinyproxy/releases/download/$pkgver/tinyproxy-$pkgver.tar.gz
	tinyproxy.initd"
pkgusers="tinyproxy"
pkggroups="tinyproxy"

prepare() {
	default_prepare
	# set default user to tinyproxy:tinyproxy and correct pidfile
	sed -i -e 's:^User.*:User tinyproxy:' \
		-e 's:^Group.*:Group tinyproxy:' \
		-e 's:^PidFile.*:PidFile "/run/tinyproxy/tinyproxy.pid":' \
		etc/tinyproxy.conf.in
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--localstatedir=/var \
		--sysconfdir=/etc \
		--disable-dependency-tracking \
		--enable-reverse
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -d -D -o tinyproxy -g tinyproxy "$pkgdir"/run/tinyproxy
	install -d -D -o tinyproxy -g tinyproxy "$pkgdir"/var/log/tinyproxy
	install -Dm755 "$srcdir"/tinyproxy.initd "$pkgdir"/etc/init.d/tinyproxy
}

sha512sums="53187adef865672a6c29f126189cf896bd02f8b0789ee2ee00b82d93b952c70dacdd2c82b0845392e518560e75e6ee107ce7662d1ec71108f293ba1d7de6aa2a  tinyproxy-1.10.0.tar.gz
cd440ed686e8128ed46441ca29da8376c4d28e9e34ae9b85c18eb2f1681d60c0c04b79401a7368f917eeab6768965d6c867d0ac6578a7858557c11b356446c02  tinyproxy.initd"
